<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id='a'>
    <div id='b'>
        <div id='c'>
        </div>
    </div>
</div>
<script>
var b = document.getElementById('b');
b.addEventListener('click', function(event) {
    var path = event.path;
    test(function () {
        assert_event_path_for_b(path);
    }, "event.path in click event");
    path[1] = '';
    test(function () {
        assert_event_path_for_b(event.path);
    }, "Make sure that event.path returns static NodeList.");
});
var clickEvent = document.createEvent("MouseEvents");
test(function () {
    assert_equals(clickEvent.path.length, 0);
}, "Make sure that event.path is empty before dispatching the event.");

clickEvent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
b.dispatchEvent(clickEvent);

function assert_event_path_for_b(path) {
    assert_equals(path.length, 6);
    assert_equals(path[0], b);
    assert_equals(path[1], a);
    assert_equals(path[2], document.body);
    assert_equals(path[3], document.documentElement);
    assert_equals(path[4], document);
    assert_equals(path[5], window);
}

test(function () {
    assert_event_path_for_b(clickEvent.path);
}, "Make sure that event.path isn't emptified after dispatching the event.");
</script>
